var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, o) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var o in t)
              Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
          })(t, o);
      };
      return function (t, o) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        e(t, o),
          (t.prototype =
            null === o
              ? Object.create(o)
              : ((i.prototype = o.prototype), new i()));
      };
    })(),
  DailySignView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_dailysign_sure.on(Laya.Event.CLICK, t, t.onDidDailysignSure),
        WebSocketService.addListener({
          caller: t,
          code: 5309,
          method: t.onLoadDailySignView,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5310,
          method: t.onLoadDailySignView,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5311,
          method: t.onLoadShopItemData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5312,
          method: t.onReqShopItemData,
        }),
        (t.list_dailysign.renderHandler = new Handler(t, t.updateItem)),
        (t.list_goodsLvl_1.selectEnable = !0),
        t.list_goodsLvl_1.on(Laya.Event.CLICK, t, t.onDidListAction),
        (t.list_goodsLvl_1.renderHandler = new Handler(t, t.updateShop1Item)),
        (t.list_goodsLvl_2.selectEnable = !0),
        t.list_goodsLvl_2.on(Laya.Event.CLICK, t, t.onDidListAction),
        (t.list_goodsLvl_2.renderHandler = new Handler(t, t.updateShop2Item)),
        (t.list_goodsLvl_3.selectEnable = !0),
        t.list_goodsLvl_3.on(Laya.Event.CLICK, t, t.onDidListAction),
        (t.list_goodsLvl_3.renderHandler = new Handler(t, t.updateShop3Item)),
        t.tab_dailysign.on(Laya.Event.CLICK, t, t.onTabDailySign),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showSignView = function () {
        return (
          null == this.signView &&
            ((this.signView = new t()), (this.signView.zOrder = 2e3)),
          this.signView.popup(!0),
          this.signView.initData(),
          this.signView
        );
      }),
      (t.prototype.initData = function () {
        (this.signsArr = [
          { count: 1, value: "1积分" },
          { count: 2, value: "1积分" },
          { count: 3, value: "1积分" },
          { count: 4, value: "1积分" },
          { count: 5, value: "1积分" },
          { count: 6, value: "2积分" },
          { count: 7, value: "1级技能书" },
          { count: 8, value: "3积分" },
          { count: 9, value: "3积分" },
          { count: 10, value: "3积分" },
          { count: 11, value: "3积分" },
          { count: 12, value: "3积分" },
          { count: 13, value: "4积分" },
          { count: 14, value: "初级副将心法" },
          { count: 15, value: "5积分" },
          { count: 16, value: "5积分" },
          { count: 17, value: "5积分" },
          { count: 18, value: "5积分" },
          { count: 19, value: "5积分" },
          { count: 20, value: "6积分" },
          { count: 21, value: "幸运符" },
          { count: 22, value: "7积分" },
          { count: 23, value: "7积分" },
          { count: 24, value: "7积分" },
          { count: 25, value: "7积分" },
          { count: 26, value: "7积分" },
          { count: 27, value: "8积分" },
          { count: 28, value: "精钢宝盒" },
        ]),
          (this.listArr = []);
        for (var e, t = 0; t < this.signsArr.length; t++) {
          var o = this.signsArr[t];
          (e = {
            item_count: { text: o.count + "次" },
            item_value_text: { text: o.value },
          }),
            this.listArr.push(e);
        }
        (this.list_dailysign.dataSource = this.listArr),
          WebSocketService.send({ c: 5309, d: { roleId: Global.roleId } }),
          (this.tab_dailysign.selectedIndex = 0),
          (this.view_dailySign.visible = !0),
          (this.view_jifen_shop.visible = !1);
      }),
      (t.prototype.onTabDailySign = function (e) {
        0 == this.tab_dailysign.selectedIndex
          ? ((this.view_dailySign.visible = !0),
            (this.view_jifen_shop.visible = !1))
          : 1 == this.tab_dailysign.selectedIndex &&
            ((this.view_dailySign.visible = !1),
            (this.view_jifen_shop.visible = !0),
            WebSocketService.send({ c: 5311, d: { roleId: Global.roleId } }));
      }),
      (t.prototype.onDidDailysignSure = function () {
        WebSocketService.send({ c: 5310, d: { goodsId: 653, count: 1 } });
      }),
      (t.prototype.onLoadDailySignView = function (e) {
        5309 == e.act_id
          ? e.data &&
            ((this.monthCount = e.data.monthCount),
            (this.text_sign_tips.text = e.msg ? e.msg : ""),
            this.list_dailysign.refresh())
          : 5310 == e.act_id &&
            (ToastView.toastView(e.msg),
            0 == e.code &&
              WebSocketService.send({ c: 5309, d: { roleId: Global.roleId } }));
      }),
      (t.prototype.updateItem = function (e, t) {
        var o = e.getChildByName("item_value_text"),
          i = e.getChildByName("item_value");
        t < this.monthCount
          ? ((o.text = "已签到"),
            (i.skin = "comp/commonpic/btn_box_gray_r.png"))
          : (i.skin = "comp/preload/btn_create_role.png");
      }),
      (t.prototype.onDidListAction = function (e) {
        if ("" != e.target.name)
          if ((console.log(e.target), "item_duihuan1" == e.target.name)) {
            t = this.list_goodsLvl_1.selectedItem;
            WebSocketService.send({
              c: 5312,
              d: { goodsId: t.goodsId, num: 1, goodsLvl: t.goodsLvl },
            });
          } else if ("item_duihuan2" == e.target.name) {
            t = this.list_goodsLvl_2.selectedItem;
            WebSocketService.send({
              c: 5312,
              d: { goodsId: t.goodsId, num: 1, goodsLvl: t.goodsLvl },
            });
          } else if ("item_duihuan3" == e.target.name) {
            var t = this.list_goodsLvl_3.selectedItem;
            WebSocketService.send({
              c: 5312,
              d: { goodsId: t.goodsId, num: 1, goodsLvl: t.goodsLvl },
            });
          }
      }),
      (t.prototype.updateShop1Item = function (e, t) {
        var o = e.getChildByName("item_duihuan1");
        if (o) {
          e.dataSource.goodsLvl <= this.cur_msg
            ? ((o.skin = "comp/commonpic/btn_dialog_sure.png"),
              (o.mouseEnabled = !0))
            : ((o.mouseEnabled = !1),
              (o.skin = "comp/commonpic/btn_dialog_silver.png"),
              (o.labelColors = "#FFF"));
        }
      }),
      (t.prototype.updateShop2Item = function (e, t) {
        var o = e.getChildByName("item_duihuan2");
        if (o) {
          e.dataSource.goodsLvl <= this.cur_msg
            ? ((o.skin = "comp/commonpic/btn_dialog_sure.png"),
              (o.mouseEnabled = !0))
            : ((o.mouseEnabled = !1),
              (o.skin = "comp/commonpic/btn_dialog_silver.png"),
              (o.labelColors = "#555"));
        }
      }),
      (t.prototype.updateShop3Item = function (e, t) {
        var o = e.getChildByName("item_duihuan3");
        if (o) {
          e.dataSource.goodsLvl <= this.cur_msg
            ? ((o.skin = "comp/commonpic/btn_dialog_sure.png"),
              (o.mouseEnabled = !0))
            : ((o.mouseEnabled = !1),
              (o.skin = "comp/commonpic/btn_dialog_silver.png"),
              (o.labelColors = "#666"));
        }
      }),
      (t.prototype.onLoadShopItemData = function (e) {
        if (e.data) {
          (this.shop1Arr = []), (this.shop2Arr = []), (this.shop3Arr = []);
          for (var t, o = void 0, i = void 0, n = 0; n < e.data.length; n++) {
            var s = e.data[n];
            1 == s.goodsLvl
              ? ((o = {
                  goodsId: s.goodsId,
                  goodsLvl: s.goodsLvl,
                  item_name_text: { text: s.goodsName },
                  item_price: { text: s.price + "积分" },
                  item_duihuan1: { label: "兑换" },
                }),
                this.shop1Arr.push(o))
              : 2 == s.goodsLvl
              ? ((i = {
                  goodsId: s.goodsId,
                  goodsLvl: s.goodsLvl,
                  item_name_text: { text: s.goodsName },
                  item_price: { text: s.price + "积分" },
                  item_duihuan2: { label: "兑换" },
                }),
                this.shop2Arr.push(i))
              : 3 == s.goodsLvl &&
                ((t = {
                  goodsId: s.goodsId,
                  goodsLvl: s.goodsLvl,
                  item_name_text: { text: s.goodsName },
                  item_price: { text: s.price + "积分" },
                  item_duihuan3: { label: "兑换" },
                }),
                this.shop3Arr.push(t));
          }
          (this.list_goodsLvl_1.dataSource = this.shop1Arr),
            (this.list_goodsLvl_2.dataSource = this.shop2Arr),
            (this.list_goodsLvl_3.dataSource = this.shop3Arr),
            (this.label_sign_more.text = "积分：" + e.more),
            (this.cur_msg = e.msg);
        }
      }),
      (t.prototype.onReqShopItemData = function (e) {
        ToastView.toastView(e.msg),
          5312 == e.act_id &&
            0 == e.code &&
            WebSocketService.send({ c: 5311, d: { roleId: Global.roleId } });
      }),
      t
    );
  })(ui.common.DailysSignViewUI);
